package com.heng.groupchat.model.dto;

import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import java.io.Serial;
import java.io.Serializable;

/**
 * 用户注册请求体
 *
 * @author faye
 */
@Data
public class UserRegisterRequest implements Serializable {

    @Serial
    private static final long serialVersionUID = 3191241716373120793L;

    /**
     * 用户账号
     */
    @NotEmpty(message = "账号不能为空！")
    @Length(min = 4, max = 10, message = "账号长度应在4到10个字符之间！")
    @Pattern(regexp = "^[a-zA-Z0-9_]+$", message = "账号包含非法字符！")
    private String username;

    /**
     * 用户密码
     */
    @NotEmpty(message = "密码不能为空！")
    @Length(min = 8, max = 16, message = "密码长度应在8到16个字符之间！")
    @Pattern(regexp = "^[a-zA-Z0-9\\W_]+$", message = "密码包含非法字符！")
    @Pattern(regexp = "^(?=.*[a-zA-Z])(?=.*\\d)(?=.*[\\W_])[\\w\\W]+$", message = "密码过于简单！")
    private String password;

    /**
     * 校验密码
     */
    @NotEmpty(message = "校验密码不能为空！")
    private String checkPassword;
}